package com.neusoft.elmboot.service.impl;

import com.neusoft.elmboot.po.Admin;
import com.neusoft.elmboot.mapper.AdminDao;
import com.neusoft.elmboot.service.AdminService;
import com.neusoft.elmboot.util.EncryptUtils;
import org.springframework.stereotype.Service;


import javax.annotation.Resource;


@Service("adminService")
public class AdminServiceImpl implements AdminService {
    @Resource
    private AdminDao adminDao;



    @Override
    public Boolean login(String id, String pass) {
        String rightPass =  adminDao.selectById(id).getPass();
        return EncryptUtils.verifyBCryptHash(pass,rightPass);
    }

    @Override
    public Integer insert(Admin admin) {
        try {
            admin.setPass(EncryptUtils.getBCryptString(admin.getPass()));
            return adminDao.insert(admin);
        }catch (Exception e){
            return null;
        }


    }


}
